from multiprocessing import Manager,Pool
import  os,time,random
def write(q):
    print('write开始启动%s，父进程号是%s'%(os.getpid(),os.getppid()))
    for i in 'end':
        q.put(i)
def read(q):
    print('read开始启动%s,父进程号是%s'%(os.getppid(),os.getppid()))
    for i in range(q.qsize()):
        print('从消息队列获取的消息是%s'%q.get())


if __name__=='__main__':
    print('star')
    q=Manager().Queue()
    po=Pool()
    po.apply_async(write,(q,))
    time.sleep(random.random())
    po.apply_async(read,(q,))
    po.close()
    po.join()
    print('end,进程号是%s'%os.getpid())